<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员-店铺审核</title>
<style type="text/css">
	#msg{width: 260px;height: 120px;}
	#d{width: 260px;margin:10px auto;}
	#d1{float: left;}
	#d2{float: right;margin-top:10px}
</style>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.5/themes/icon.css">
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="js/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
	<script>
	var row="";
//同意	
	function agree(){
		$.ajax({
			url:'Res?method=agree',
			type:'post',
			data:{
				rid:row.rid,
				uid:row.uid
			},
			success:function(d){
				if(d=="1"){
				$.ajax({
					type:"post",
					url:"sendMessage",
					dataType:"json",
					data:{
						"message":"您添加的餐厅"+row.rname+"审核通过！",
						"getter":row.uid
					},
					success:function(e){
						if(e.result){
						  	$.messager.show({
								title:'提示',
								width:300,
								height:200,
								msg:'['+row.rid+']'+row.rname+'审核通过',
								timeout:3000,
								showType:'slide'
							});
							$('#dg').datagrid('reload'); 
						}
					}
			})
			}
			}
		})
	}
//拒绝	
	function disagree(){
		console.log(row.rid)
		$.ajax({
			url:'Res?method=agree',
			type:'post',
			data:{
				rid:row.rid,
				dis:'1'
			},
			success:function(d){
				if(d=="1"){
					$.ajax({
						type:"post",
						url:"sendMessage",
						dataType:"json",
						data:{
							"message":"您添加的餐厅"+row.rname+"审核不通过!<br />原因:"+$("#msg").val(),
							"getter":row.uid
						},
						success:function(e){
							if(e.result){
							  	$.messager.show({
									title:'提示',
									width:300,
									height:200,
									msg:'['+row.rid+']'+row.rname+'已拒绝',
									timeout:3000,
									showType:'slide'
								});
							  	$('#win').window('close');
								$('#dg').datagrid('reload'); 
							}
						}
				})
				}
			}
		})
	}	
	$(function(){
		$('#win').window('close');
		$('#dg').datagrid({
			singleSelect:true,
		    url:'Res?method=appr',
		    columns:[[
				{field:'rid',title:'店铺编号',width:60},
				{field:'rname',title:'店铺名称',width:100},
				{field:'rloc',title:'地址',width:100},
				{field:'rtel',title:'电话',width:100},
				{field:'rkey',title:'关键字',width:50},
				{field:'rbh',title:'营业时间',width:100},
				{field:'roveralls',title:'总体评分',width:60},
				{field:'rtastes',title:'口味评分',width:60},
				{field:'renvs',title:'环境评分',width:60},
				{field:'rsvcs',title:'服务评分',width:60},
				{field:'rtotalass',title:'评价条数',width:60},
				{field:'rimg',title:'图片地址',width:100},
				{field:'rintime',title:'收录时间',width:150},
				{field:'reason',title:'收录理由',width:100},
				{field:'uid',title:'收录人ID',width:100},
				{field:'rstatus',title:'待审核',width:50},
		    ]],
	    toolbar: [{
			iconCls: 'icon-back',
			handler: function(){
				location.href='aRestaurant.html';
				
				}
		},'-',{
			iconCls: '',
			handler: function(){
			
				}
		},'-',{
			iconCls: 'icon-ok',
			handler: function(){
				row=$('#dg').datagrid('getSelected');
				if(row!=null){
					agree();
					}
				}
		},'-',{
			iconCls: '',
			handler: function(){
			
				}
		},'-',{
			iconCls: 'icon-cancel',
			handler: function(){
				row=$('#dg').datagrid('getSelected');
				if(row!=null){
					$('#win').window('open');
					}
				}
		}],
	});
	$("#btn").click(function(){
			disagree();
	})
	})

	</script>
</head>
<body>
<table id="dg" width="1350" data-options="striped:true,pagination:true"></table>
<div id="win" class="easyui-window" title="拒绝原因" style="width:360px;height:230px"
	    data-options="iconCls:'icon-save',modal:true">
	 	<div id="d">
	<div id="d1"><textarea id="msg"></textarea>
</div>
<div id="d2">
	<button id="btn">确定</button>
</div>
	    </div>
	     </div>
</body>
</html>